initializeStore
POST /v2/pds/store/initializeStore
The F&B (food and beverage) mini program relies on the SaaS provider or Independent Software Vendor (ISV) to feed full data. With this API call, the SaaS provider or ISV can complete the full data synchronization of the store list.
Note: To execute the full data synchronization, follow the steps below:
- (Optional) Full synchronization of all shopping areas via the initializeShoppingArea API. Maximum 50 shopping areas per API call. This step is required when areaId is requested in the initializeStore API.
- (Optional) Full synchronization of all brands via the initializeBrand API. Maximum 50 brands per API call. This step is required when brandId is requested in the initializeStore API.
- Full synchronization of all stores via the initializeStore API. 20 stores at most for one API call. The store data object includes menu, category, item, SKU, and modifier group information.
Structure
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:
Request parameters
Field | Data type | Required | Description | Example |
appId | String | No | Indicates the unique ID assigned by Mini Program Platform to identify a mini program.
Note: Obtain this field via the my.getAppIdSync JSAPI or Mini Program Platform. | "2102010113769***" |
requestId | String | Yes | Indicates the unique ID assigned by the SaaS provider or ISV to identify a request for the full synchronization of stores.
Note: This field is an idempotency field.
| "store_2022012111061234567890" |
stores | Array<InitStore> | Yes | Indicates a list of the InitStore object.
| - |
InitStore
InitMenu
Field | Data type | Required | Description |
menuInfo | Yes | Indicates the details of the menu. | |
categories | Array<InitCategory> | Yes | Indicates a list of the InitCategory object.
|
InitCategory
InitItem
Field | Data type | Required | Description |
itemInfo | Yes | Indicates the details of the item. | |
modifierGroups | Array<InitModifierGroup> | No | Indicates a list of the InitModifierGroup object.
Note: If groupId of multiple modifier groups in the same store is the same, it means that the same group object can be used in multiple items and the data in the first record will be gained. |
InitModifierGroup
Field | Data type | Required | Description |
modifierGroupInfo | Yes | Indicates the details of the modifier group. | |
childItems | Array<InitItem> | Yes | Indicates a list of add-on items in the modifier group.
Note: If itemId of multiple items in the same modifier group in the store is the same, it means that the same item object can be used in multiple modifier groups and the data in the first record will be gained. |
Response parameters
Field | Data type | Required | Description |
result | Yes | Indicates the request result such as status and error codes. |
Result process logic
In the response, the result.resultStatus field indicates the result of processing a request. The following table describes each result status:
Result status | Description |
A | The request for full data synchronization of stores is accepted by us. The corresponding result.resultCode and result.resultMessage may vary based on different situations. For details, see the following Error codes section. |
S | The full data synchronization of stores is successful. The corresponding result.resultCode is |
U | The status of full data synchronization of stores is unknown. The corresponding result.resultCode is For details, see the Common error codes section. |
F | The full data synchronization of stores failed. The corresponding result.resultCode and result.resultMessage may vary based on different situations. For details, see the following Error codes section. |
More information
To specify the skus and skuPropertyGroups parameters, follow the rule below:
- For items with SKU information, both skus and skuPropertyGroups are required.
- Within one item (specified by the itemId parameter), the Sku.skuPropertyPairs parameter is specified according to skuPropertyGroups:
- For each key-value pair (specified by the Sku.skuPropertyPairs parameter), key is specified according to skuPropertyGroups.propertyGroupKey.
- Value is specified according to SkuProperty.propertyValue.
- Within one item (specified by the itemId parameter), the key-value pairs for any SKU (specified by the skuId parameter) must be unique and cover all SkuPropertyGroup.propertyGroupKey you pass.
To learn more, see Request sample.
Error codes
Error codes are usually classified into the following categories:
- Common error codes are common for F&B mini program OpenAPIs.
Samples
Request
{
"appId":"2102010113769***",
"requestId": "0542f0f3a0c942a982c585e76bfe6f92",
"stores": [
{
"storeInfo": {
"areaId": "A39239",
"storeId": "ST7956",
"name": "Store D",
"storeType": "HAWKER",
"address": "Toy Centre,Road C,District B,City A,Country Z",
"images": [
"https://www.example.com/iamges/cdZOWIR73/0011icon.jpg"
],
"announcement": [
{
"contentType": "TEXT",
"value": "hello,this is Store D in Toy Hawker"
}
],
"description": "Delicious food, Just for you",
"location": {
"latitude": "30",
"longitude": "120",
"postCode": "999999"
},
"timeZone": "GMT+8:00",
"cuisine": "ethnic food",
"contactPhoneNos": [
"99999999"
],
"pickUpAddress": "door one in TOY Centre",
"pickUpContactDetails": [
{
"name": "Will",
"phoneNo": "9999999"
}
],
"banners": [
{
"imageUrl": "https://www.example.com/images/antfincdn/dPRmkkfWX/0161icon.jpg",
"landingUrl": "https://www.example.com"
}
],
"recommendItemIds": [
"singleitem789",
"singleitem3214"
]
},
"menus": [
{
"menuInfo": {
"menuId": "055",
"storeId": "ST7956",
"menuType": "PICKUP",
"title": "Ali Shan",
"subTitle": "",
"description": "",
"pickUpRules": [
{
"endTime": "12:00",
"startTime": "10:00",
"step": "30",
"supportDays": 2,
"minPrepareMinutes": 15
},
{
"endTime": "17:00",
"startTime": "22:00",
"step": "30",
"supportDays": 2,
"minPrepareMinutes": 15
}
]
},
"categories": [
{
"categoryInfo": {
"storeId": "ST7956",
"menuId": "055",
"categoryId": "005",
"title": "Others",
"subTitle": "",
"icon": "https://www.example.com/images/antfincdn/cdZOWIR73/0011icon.jpg"
},
"items": [
{
"categoryId": "005",
"itemInfo": {
"quantityRule": {
"min": 0,
"max": 99
},
"itemTitle": "Stir Fried Hor Fun",
"itemId": "singleitem123",
"images": [
"https://www.example.com/images/uploads/meals/0f61dfab72cf2de02248cee773f990ca.JPG"
],
"priceInfo": {
"originAmount": 120,
"saleAmount": 100,
"currency": "SGD"
},
"serviceAvailabilityList": [
{
"dayOfWeek": "MONDAY",
"timePeriods": [
{
"description": "timePeriod desc",
"startTime": "10:00",
"endTime": "22:00"
}
]
},
{
"dayOfWeek": "SUNDAY",
"timePeriods": [
{
"description": "timePeriod desc",
"startTime": "10:59",
"endTime": "22:00"
}
]
}
],
"itemStatus": "AVAILABLE",
"itemDescription": "delicious",
"skuPropertyGroups": [
{
"propertyGroupName": "size",
"propertyGroupKey": "27731",
"properties": [
{
"propertyName": "Small",
"propertyValue": "Small"
},
{
"propertyName": "Large",
"propertyValue": "Large"
}
]
},
{
"propertyGroupKey": "27733",
"propertyGroupName": "Level of Spiciness",
"properties": [
{
"propertyName": "No Chilli",
"propertyValue": "No Chilli"
},
{
"propertyName": "Less Chilli",
"propertyValue": "Less Chilli"
},
{
"propertyName": "Extra Chilli",
"propertyValue": "Extra Chilli"
},
{
"propertyName": "Normal Spicy",
"propertyValue": "Normal Spicy"
}
]
}
],
"skus": [
{
"image": "https://www.example.com/images/uploads/meals/0f62cf2de02248cee773f990ca.JPG",
"priceInfo": {
"originAmount": 100,
"saleAmount": 90,
"currency": "SGD"
},
"skuId": "tsku2121",
"skuPropertyPairs": {
"27731": "Small",
"27733": "Normal Spicy"
}
},
{
"image": "https://wwww.example.com/images/uploads/meals/2cf2dfssdmgkeqec1c.png",
"priceInfo": {
"originAmount": 100,
"saleAmount": 80,
"currency": "SGD"
},
"skuId": "tsku2122",
"skuPropertyPairs": {
"27731": "Large",
"27733": "Normal Spicy"
}
}
]
},
"modifierGroups": [
{
"modifierGroupInfo": {
"groupName": "food main",
"groupId": "tpgroup123",
"quantityRule": {
"min": 0,
"max": 10
}
},
"childItems": [
{
"itemInfo": {
"itemTitle": "chicken",
"itemId": "addonItem256",
"itemStatus": "AVAILABLE",
"itemDescription": "",
"priceInfo": {
"saleAmount": 50,
"currency": "SGD"
}
},
"modifierGroups": [
{
"modifierGroupInfo": {
"groupName": "side dish",
"groupId": "tpgroup222",
"quantityRule": {
"min": 0,
"max": 1
}
},
"childItems": [
{
"itemInfo": {
"itemTitle": "lettuce",
"itemId": "addonItem456",
"itemStatus": "AVAILABLE",
"itemDescription": "",
"priceInfo": {
"originAmount": 20,
"saleAmount": 10,
"currency": "SGD"
}
}
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
Business rules for Store
The following code excerpts demonstrate the business rules of a store:
Specify delivery distance rule
{
"businessRule": [
{
"scene": "DELIVERY_DISTANCE",
"ruleData": "[{\"from\":0,\"to\":5000,\"fee\":{\"currency\":\"SGD\",\"amountValue\":500},\"minimumOrderAmount\":{\"currency\":\"SGD\",\"amountValue\":1000},\"discounts\":[{\"discountType\":\"REDUCE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"amountValue\":1000},\"discountValue\":\"{\\\"currency\\\": \\\"SGD\\\", \\\"amountValue\\\":1000}\"},{\"discountType\":\"PERCENTAGE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"amountValue\":100},\"discountValue\":\"20\"},{\"discountType\":\"EXEMPTION\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"amountValue\":3000}}]},{\"from\":5000,\"to\":10000,\"fee\":{\"currency\":\"SGD\",\"amountValue\":1000},\"minimumOrderAmount\":{\"currency\":\"SGD\",\"amountValue\":2000},\"discounts\":[{\"discountType\":\"REDUCE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"amountValue\":2000},\"discountValue\":\"{\\\"currency\\\": \\\"SGD\\\", \\\"amountValue\\\":1000}\"},{\"discountType\":\"PERCENTAGE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"amountValue\":3000},\"discountValue\":\"20\"},{\"discountType\":\"EXEMPTION\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"amountValue\":4000}}]},{\"from\":10000,\"to\":100000,\"fee\":{\"currency\":\"SGD\",\"amountValue\":2000},\"minimumOrderAmount\":{\"currency\":\"SGD\",\"amountValue\":5000},\"discounts\":[{\"discountType\":\"REDUCE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"amountValue\":5000},\"discountValue\":\"{\\\"currency\\\": \\\"SGD\\\", \\\"amountValue\\\":1000}\"},{\"discountType\":\"PERCENTAGE\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"amountValue\":6000},\"discountValue\":\"20\"},{\"discountType\":\"EXEMPTION\",\"orderThresholdAmount\":{\"currency\":\"SGD\",\"amountValue\":7000}}]}]"
}
]
}
Specify delivery schedule
{
"businessRule": [
{
"scene": "DELIVERY_SCHEDULE",
"ruleData": "[{\"scheduleType\":\"WEEKLY\",\"supportDays\":30,\"schedules\":{\"MONDAY\":[{\"startTime\":\"10:00\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"TUESDAY\":[{\"startTime\":\"10:10\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"WEDNESDAY\":[{\"startTime\":\"10:20\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"THURSDAY\":[{\"startTime\":\"10:30\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"FRIDAY\":[{\"startTime\":\"10:40\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"SATURDAY\":[{\"startTime\":\"10:50\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"SUNDAY\":[{\"startTime\":\"11:00\",\"endTime\":\"11:30\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}]}}]"
}
]
}
Specify pickup rule
{
"businessRule": [
{
"scene": "PICKUP_RULE",
"ruleData": "[{\"minimumOrderAmount\":{\"currency\":\"SGD\",\"amountValue\":1800}}]"
}
]
}
Specify pickup schedule
{
"businessRule": [
{
"scene": "PICKUP_SCHEDULE",
"ruleData": "[{\"scheduleType\":\"WEEKLY\",\"supportDays\":30,\"schedules\":{\"MONDAY\":[{\"startTime\":\"10:00\",\"endTime\":\"12:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"TUESDAY\":[{\"startTime\":\"10:10\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"WEDNESDAY\":[{\"startTime\":\"10:20\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"THURSDAY\":[{\"startTime\":\"10:30\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"FRIDAY\":[{\"startTime\":\"10:40\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"SATURDAY\":[{\"startTime\":\"10:50\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"SUNDAY\":[{\"startTime\":\"11:00\",\"endTime\":\"11:30\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}]}}]"
}
]
}
Specify dine-in order rule
{
"businessRule": [
{
"scene": "DINE_IN_ORDER",
"ruleData": "{\"isTableNoRequired\": false,\"serviceType\": \"SERVE_TO_TABLE\"}"
}
]
}
Specify dine-in schedule
{
"businessRule": [
{
"scene": "DINE_IN_SCHEDULE",
"ruleData": "[{\"scheduleType\":\"WEEKLY\",\"supportDays\":31,\"schedules\":{\"MONDAY\":[{\"startTime\":\"09:00\",\"endTime\":\"12:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"TUESDAY\":[{\"startTime\":\"10:10\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"WEDNESDAY\":[{\"startTime\":\"10:20\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"THURSDAY\":[{\"startTime\":\"10:30\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"FRIDAY\":[{\"startTime\":\"10:40\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"SATURDAY\":[{\"startTime\":\"10:50\",\"endTime\":\"11:00\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}],\"SUNDAY\":[{\"startTime\":\"11:00\",\"endTime\":\"11:30\"},{\"startTime\":\"12:00\",\"endTime\":\"13:00\"},{\"startTime\":\"14:00\",\"endTime\":\"15:00\"},{\"startTime\":\"18:00\",\"endTime\":\"20:00\"},{\"startTime\":\"21:00\",\"endTime\":\"22:00\"}]}}]"
}
]
}
Business rules for Item
The following code excerpts demonstrate the business rules of an item:
Specify price rule
{
"businessRule": [
{
"scene": "PRICE_SCHEDULE",
"ruleData": "[{\"from\": \"2022-09-21T00:00:01+08:00\",\"to\": \"2022-12-31T01:00:01+08:00\",\"weekDays\": [\"MONDAY\",\"WEDNESDAY\",\"TUESDAY\"],\"timeSlot\": {\"startTime\": \"10:00\",\"endTime\": \"14:00\"},\"originAmount\":200,\"saleAmount\":180,\"currency\": \"SGD\"}]"
}
]
}
Specify item status rule
{
"businessRule": [
{
"scene": "ITEM_STATUS_RULE",
"ruleData": "[{\"from\":\"2022-09-01T00:00:01+08:00\",\"to\": \"2022-12-31T01:00:01+08:00\",\"weekDays\": [\"MONDAY\",\"WEDNESDAY\",\"TUESDAY\"],\"timeSlot\": {\"startTime\": \"10:00\",\"endTime\": \"14:00\"},\"itemStatus\":\"AVAILABLE\"}]"
}
]
}
Business rules for Sku
The following code excerpts demonstrate the business rules for an SKU:
Specify price rule
{
"businessRule": [
{
"scene": "PRICE_SCHEDULE",
"ruleData": "[{\"from\": \"2022-09-09T11:00:01+08:00\",\"to\": \"2022-12-31T01:00:01+08:00\",\"weekDays\": [\"MONDAY\",\"WEDNESDAY\",\"TUESDAY\"],\"timeSlot\": {\"startTime\": \"10:00\",\"endTime\": \"15:00\"},\"originAmount\":200,\"saleAmount\":180,\"currency\": \"SGD\"}]"
}
]
}
Specify SKU status rule
{
"businessRule": [
{
"scene": "SKU_STATUS_RULE",
"ruleData": "[{\"from\":\"2022-09-01T00:00:01+08:00\",\"to\": \"2022-12-31T01:00:01+08:00\",\"weekDays\": [\"MONDAY\",\"WEDNESDAY\",\"TUESDAY\"],\"timeSlot\": {\"startTime\": \"10:00\",\"endTime\": \"14:00\"},\"skuStatus\":\"AVAILABLE\"}]"
}
]
}
Response
{
"result": {
"resultCode": "SUCCESS",
"resultStatus": "S",
"resultMessage": "success"
}
}